#include "PoissonNode.h"

#include <QDebug>
#include <math.h>
PoissonNode::PoissonNode(Node *rate, double sampleValue, bool isObserved) :
    Node(POISSON, sampleValue, isObserved),
    rate(rate)
{
    rate->addChild(this);
}

PoissonNode::PoissonNode(const PoissonNode& other) :
    Node(other),
    rate(other.rate)
{

}

PoissonNode::~PoissonNode()
{

}

double PoissonNode::logLikelihood(double x)
{
    int k = (int) x;
    return log(Distribution::sharedInstance()->likelihoodPoisson(k, rate->getLastSample()));
}
